/**      
 * @file		structInAStruct.cpp
 * @description		This example demonstrates the use of a struct
 *			within a struct. C++ and other OO (Object Oriented)
 *			languages provide the flexibility to create your
 *			software as you envision it. So there are instances
 *			where you want to create such software where one entity
 *			contains another. This is an example of that. We will
 *			see more when we re-address inheritance and class hierarchy.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <iostream>
#include <cstring>
using namespace std;

// Notice the enclosed struct must
// be defined before it is used
struct Person {
	char mName[256];
	char mSSID[10];
};

struct Student {
	Person mPerson;		// struct can be part of another struct
	char mSID[256];		// student id
};

struct Instructor {
	Person mPerson;		// struct can be part of another struct
	double mSalary;
};

/**
 * @return zero if the application executes successfully
 */
int main() {
	Student student;
	Instructor instructor;
	
	strcpy(student.mPerson.mName, "Brad Rippe");
	strcpy(student.mPerson.mSSID, "000000000");
	strcpy(student.mSID,"@00000001");

	cout << "Student name " << student.mPerson.mName << endl;
	cout << "Student social " << student.mPerson.mSSID << endl;
	cout << "Student student id " << student.mSID << endl;

	instructor.mPerson = student.mPerson;
	instructor.mSalary = 2000.00;

	cout.setf(ios::showpoint);
	cout.setf(ios::fixed);
	cout.precision(2);

	cout << "Instr name " << instructor.mPerson.mName << endl;
	cout << "Instr social " << instructor.mPerson.mSSID << endl;
	cout << "Instr salary $" << instructor.mSalary << endl;

	// Notice, if I modify the Person in student, the instructor isn't 
	// changed
	strcpy(student.mPerson.mName, "John Doe");
	cout << "Student name " << student.mPerson.mName << endl;
	cout << "Instr name " << instructor.mPerson.mName << endl;

	return 0;
}

